package com.qf.ssm.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.qf.ssm.constans.ResultCode;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class R {
    private int code;
    private String  msg;
    private Object data;

    public static R OK(){
        return OK(null);
    }
    public static R OK(Object data){
        return getResult(ResultCode.SUCCESS,"成功",data);
    }
    public static R ERROR(){
        return ERROR(null);
    }
    public static R ERROR(Object data){
        return getResult(ResultCode.FAIL,"失败",null);
    }
    public static R getResult(int code, String msg){
        return getResult(code,msg,null);
    }
    public static R getResult(int code,String msg,Object data){
        R r = new R();
        r.setCode(code);
        r.setData(data);
        r.setMsg(msg);
        return r;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
